package com.ymatou.cs.api.testcase;

import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.cs.api.parameter.ApplyForYmtAPPBean;
import com.ymatou.cs.api.parameter.Img;
import com.ymatou.cs.api.service.ApplyForYmtAPPCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
 * 申请本地退货接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_ApplyForYmtAPP {
	private static ApplyForYmtAPPBean appbean;
	private static ApplyForYmtAPPCall appcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("申请本地退货接口");
	}

	@Before
	public void caseUp() {
		appbean = new ApplyForYmtAPPBean();
		appcall = new ApplyForYmtAPPCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(appcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_001() {
		Logger.start(true,"申请本地退货成功");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			List<String> imgUrlList = dw.selectLocalReturnInfoImgUrlByOrderid((Integer) m.get("OrderId"));
			if (imgUrlList.size() > 0) {
				Logger.comment("总共有" + imgUrlList.size() + "张图片");
				for (int i = 0; i < imgUrlList.size(); i++) {
					Logger.verifyNotNull(imgUrlList.get(i), "验证第" + (i + 1) + "张图片地址非空");
					Logger.verifyEquals(true,
							TestDataManager.isPic(new File(TestDataManager.DownloadFile(imgUrlList.get(i)))), "验证第"
									+ (i + 1) + "张图片:" + imgUrlList.get(i) + "是否是图片");
				}
			} else {
				Logger.comment("图片url为空");
				org.junit.Assert.fail();
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_002() {
		Logger.start(true,"订单编号不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			// appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("申请退货时异常:获取订单信息失败!", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_003() {
		Logger.start(true,"买家编号不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			// appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("申请退货时异常:获取订单信息失败!", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_004() {
		Logger.start(true,"联系人手机不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			// appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_005() {
		Logger.start(true,"联系人手机最长为20个字符");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			// String mobile=TestDataManager.getPhoneNum();
			String mobile = TestDataManager.randomStr(21);
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			// appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_006() {
		Logger.start(true,"联系人邮箱不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			// String mobile=TestDataManager.randomStr(21);
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			// appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_007() {
		Logger.start(true,"联系人邮箱最长为200个字符");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			// String email=TestDataManager.getEmail();
			String email = TestDataManager.randomStr(201);
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("Email长度不能超过200", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_008() {
		Logger.start(true,"退货件数不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			// appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("退货件数不能为空", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_009() {
		Logger.start(true,"退款金额不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			// appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("退款金额不能为空", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_010() {
		Logger.start(true,"退货理由ID不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			// appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_011() {
		Logger.start(true,"退货凭证不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			// appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_012() {
		Logger.start(true,"退货说明不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			// appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_013() {
		Logger.start(true,"退货说明最长为500个字符");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			String remark = TestDataManager.randomStr(501);
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark(remark);
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("Remark长度不能超过500", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_014() {
		Logger.start(true,"图片内容不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			// String remark=TestDataManager.randomStr(501);
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			// img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_015() {
		Logger.start(true,"图片类型不能为空");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			// String remark=TestDataManager.randomStr(501);
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			// img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_016() {
		Logger.start(true,"已经存在退货信息，不可重复提交");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			// String remark=TestDataManager.randomStr(501);
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyNotEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			Logger.verifyEquals("申请退货时异常:已经存在退货信息，不可重复提交!", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_017() {
		Logger.start(true,"图片格式为其它类型");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img.setImgExt(".txt");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyEquals("60101", appcall.getCode(), "验证Code");
			Logger.verifyEquals("申请退货时异常:保存退货凭证失败，上传图片服务返回图片地址为空。", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_018() {
		Logger.start(true,"小图片文件");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img = new Img();
			img.setImgData(TestDataManager.getBase64("./resource/small.jpg"));
			img.setImgExt(".jpg");
			imgList.add(img);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			List<String> imgUrlList = dw.selectLocalReturnInfoImgUrlByOrderid((Integer) m.get("OrderId"));
			if (imgUrlList.size() > 0) {
				Logger.comment("总共有" + imgUrlList.size() + "张图片");
				for (int i = 0; i < imgUrlList.size(); i++) {
					Logger.verifyNotNull(imgUrlList.get(i), "验证第" + (i + 1) + "张图片地址非空");
					Logger.verifyEquals(true,
							TestDataManager.isPic(new File(TestDataManager.DownloadFile(imgUrlList.get(i)))), "验证第"
									+ (i + 1) + "张图片:" + imgUrlList.get(i) + "是否是图片");
				}
			} else {
				Logger.comment("图片url为空");
				org.junit.Assert.fail();
			}
			// Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ApplyForYmtAPP_019() {
		Logger.start(true,"上传多张图片文件");
		try {
			Map m = new OrderCallService().appSaveOrder();
			DefaultWapper dw = new DefaultWapper();
			dw.updateOrderbCanLocalReturn((Integer) m.get("OrderId"));
			Thread.sleep(5000);
			String email = TestDataManager.getEmail();
			String mobile = TestDataManager.getPhoneNum();
			String ReasonID = TestDataManager.getRandomUUID().toString();
			ArrayList<Img> imgList = new ArrayList<Img>();
			Img img1 = new Img();
			img1.setImgData(TestDataManager.getBase64("./resource/small.jpg"));
			img1.setImgExt(".jpg");
			Img img2 = new Img();
			img2.setImgData(TestDataManager.getBase64("./resource/baidu.gif"));
			img2.setImgExt(".gif");
			Img img3 = new Img();
			img3.setImgData(TestDataManager.getBase64("./resource/upload.jpg"));
			img3.setImgExt(".jpg");
			Img img4 = new Img();
			img4.setImgData(TestDataManager.getBase64("./resource/upload.png"));
			img4.setImgExt("png");
			Img img5 = new Img();
			img5.setImgData(TestDataManager.getBase64("./resource/Penguins.jpg"));
			img5.setImgExt(".jpg");
			Img img6 = new Img();
			img6.setImgData(TestDataManager.getBase64("./resource/upload.bmp"));
			img6.setImgExt(".bmp");
			imgList.add(img1);
			imgList.add(img2);
			imgList.add(img3);
			imgList.add(img4);
			imgList.add(img5);
			imgList.add(img6);
			BigDecimal Money = (BigDecimal) m.get("TotalPrice");
			appbean.setBuyerId((Integer) m.get("UserId"));
			appbean.setOrderId((Integer) m.get("OrderId"));
			appbean.setCount(1);
			appbean.setEmail(email);
			appbean.setMobile(mobile);
			appbean.setReasonID(ReasonID);
			appbean.setRemark("备注");
			appbean.setMoney(Money);
			appbean.setImgList(imgList);
			appcall.setData(appbean);
			appcall.callService();
			Logger.comment("发送appcall报文:" + appcall.getEntityString());
			Logger.comment("返回appcall报文：" + appcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, appcall.getCode(), "验证Code");
			List<String> imgUrlList = dw.selectLocalReturnInfoImgUrlByOrderid((Integer) m.get("OrderId"));
			if (imgUrlList.size() > 0) {
				Logger.comment("总共有" + imgUrlList.size() + "张图片");
				for (int i = 0; i < imgUrlList.size(); i++) {
					Logger.verifyNotNull(imgUrlList.get(i), "验证第" + (i + 1) + "张图片地址非空");
					Logger.verifyEquals(true,
							TestDataManager.isPic(new File(TestDataManager.DownloadFile(imgUrlList.get(i)))), "验证第"
									+ (i + 1) + "张图片:" + imgUrlList.get(i) + "是否是图片");
				}
			} else {
				Logger.comment("图片url为空");
				org.junit.Assert.fail();
			}
			// Logger.verifyEquals("", appcall.getMsg(), "验证Msg");
			// Logger.comment("图片URL:"+ImgUrl);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	// 创建压测数据
	// @Test
	// @Category(P3.class)
	// @TestCase
	// public void CreateOrders(){
	// Logger.start(true,"小图片文件");
	// try {
	// for (int i=1;i<2001;i++){
	// Map m=new OrderCallService().appSaveOrder();
	// Logger.comment("OrderID:"+i+":"+m.get("OrderId"));
	// }
	//
	// } catch (Exception e) {
	// Logger.fail(e);
	// }
	//
	// }

}
